package com.example.NeteaseCloudMusicApi.ui.adapter;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.recyclerview.widget.RecyclerView;

import com.example.NeteaseCloudMusicApi.R;
import com.example.NeteaseCloudMusicApi.entity.News;

import java.util.List;

public class KtvAdapter extends RecyclerView.Adapter<KtvAdapter.ViewHolder> {

    private List<News> mNews;


    public static class ViewHolder extends RecyclerView.ViewHolder{
        ImageView songImage;
        TextView songName;
        public ViewHolder (View view) {
            super(view);
            songImage = view.findViewById(R.id.showImage_start);
            songName = view.findViewById(R.id.song_list_introduction);
        }
    }

    public KtvAdapter(List<News> news){
        mNews = news;
        }
        @Override
        public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType){
            View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_home_pager_content,parent,false);
            ViewHolder holder = new ViewHolder(view);
            return holder;
        }

        @Override
        public void onBindViewHolder(ViewHolder holder, int position){

            News news = mNews.get(position);
            holder.songImage.setImageResource(news.getImageId());
            holder.songName.setText(news.getName());
        }

        @Override
        public int getItemCount(){
            return mNews.size();
        }
}
